package com.cskaoyan.service.wx.home;

import com.cskaoyan.bean.wx.home.WXAd;
import com.cskaoyan.bean.wx.home.WXAdExample;
import com.cskaoyan.bean.wx.home.vo.BannerVo;
import com.cskaoyan.mapper.home.WXAdMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建日期: 2022/05/08 12:15
 *
 * @author JinLu Zhou
 */
@Service
public class WXAdServiceImpl implements WXAdService {
    @Autowired
    WXAdMapper wxAdMapper;

    @Override
    public List<BannerVo> queryAllBanner() {
        WXAdExample wxAdExample = new WXAdExample();
        WXAdExample.Criteria criteria = wxAdExample.createCriteria();
        criteria.andDeletedEqualTo(false);
        List<WXAd> wxAds = wxAdMapper.selectByExample(wxAdExample);
        ArrayList<BannerVo> bannerVos = new ArrayList<>();
        for (WXAd wxAd : wxAds) {
            BannerVo bannerVo = new BannerVo();
            bannerVo.set(wxAd);
            bannerVos.add(bannerVo);
        }
        return bannerVos;
    }
}
